<template>
  <div>
    <el-drawer
      custom-class="wxkj-drawer improper-drawer"
      title="选择不合适原因"
      :before-close="drawerClose"
      :visible.sync="drawerShow"
      size="500"
    >
      <div class="drawer-content">
        <div class="ml30 mb20">
          <el-checkbox
          v-model="form.emailFlag"
            >同时向<span v-html="name"></span>发送邮件通知</el-checkbox
          >
        </div>
        <div class="ml30 mb20">应聘职位：{{jobName}}</div>
        <div class="ml30 mb20">
          <div class="mb10" v-for="(item,index) in reasonsList" :key="index">
            <el-radio :label="item.label" v-model="form.type">{{item.title}}</el-radio>
          </div>
        </div>
        <div class="fr">
          <el-button @click="drawerClose">取消</el-button>
            <el-button type="primary" @click="submitForm" :loading="submitLoading">确定</el-button>
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import {editState } from "@/api/personnel";
export default {
  data() {
    return {
      drawerShow: false,
        submitLoading: false,
      name: "",
      jobName:'',
      reasonsList:[
        {
          label: '0',
          title:'工作经验不符合要求'
        },
        {
          label: '1',
          title:'技术经验不符合岗位要求'
        },
        {
          label: '2',
          title:'月薪不匹配'
        },
        {
          label: '3',
          title:'学历不匹配'
        },
        {
          label: '4',
          title:'行业不匹配'
        },
        {
          label: '5',
          title:'招聘类型不匹配'
        },
      ],
      form:{
        type:'0',
        state:2,
        dataId:'',
        emailFlag: false
      }
    };
  },
  // 方法
  methods: {
    // 显示
    show(name,dataId,jobName) {
      this.name = name;
      this.form.dataId = dataId;
      this.jobName = jobName;
      this.drawerShow = true;
    },
    // 提交
    submitForm() {
      this.submitLoading = true;
      editState(this.form
      ).then(res => {
        this.$message({
        message: "发送成功",
        type: "success",
        });
        this.submitLoading = false;
        this.drawerClose();
      }).catch(err => {
                this.submitLoading = false;
              });
        
    },
    drawerClose() {
      this.form = {
        type:'0',
        state:2,
        dataId:'',
        emailFlag: false
      }
      this.drawerShow = false;
      this.$emit("refresh");
    },

  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  // 销毁
  destroyed() {},
};
</script>
<style lang="scss" scoped>
</style>